package com.dmxh.controller;

import com.dmxh.result.Result;
import com.dmxh.service.AddressService;
import com.dmxh.vo.AddressVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/address")
public class AddressController {

    @Autowired
    private AddressService addressService;

    @GetMapping
    public Result queryAddress(){
        return Result.ok().setData(this.addressService.queryAddress());
    }

    @PostMapping
    public Result saveAddress(@RequestBody AddressVo addressVo){
        return Result.ok().setData(this.addressService.saveAddress(addressVo));
    }

    @PutMapping
    public Result updateAddress(@RequestBody AddressVo addressVo){
        return Result.ok().setData(this.addressService.updateAddress(addressVo));
    }

    @DeleteMapping
    public Result deleteAddress(@RequestParam String id){
        return Result.ok().setData(this.addressService.deleteAddress(id));
    }


    /*通过地址id查询*/
    @GetMapping("/addressByIdQueryAll")
    public AddressVo addressByIdQueryAll(@RequestParam Long addressId){
        return this.addressService.addressByIdQueryAll(addressId);
    }
}
